﻿<common:UserControlBase x:Class="Sesa.Desktop.Views.TestimonyEditView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:common="clr-namespace:Sesa.Desktop.Common"
            xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:views="clr-namespace:Sesa.Desktop.Views"
                        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                        xmlns:controls="clr-namespace:FarsiLibrary.FX.Win.Controls;assembly=FarsiLibrary.FX.Win"
                        DataContext="{Binding Source={StaticResource Locator}, Path=TestimonyEditViewModel}"
             >
  <StackPanel Orientation="Vertical">
    <StackPanel Orientation="Vertical">
      <StackPanel Orientation="Horizontal">
        <common:LayoutItem Label="تعداد" Width="{StaticResource DefaultUnitWidth}">
          <TextBox Text="{Binding Entity.ProductCount,ValidatesOnDataErrors=True}" Style="{StaticResource TextBoxStyle}"/>
        </common:LayoutItem>
        <Button Command="{Binding CalculateCommand}" Content="محاسبه مواد لازم"/>
      </StackPanel>
      <StackPanel Orientation="Horizontal">
        <common:LayoutItem Label="تاریخ" Width="{StaticResource DefaultUnitWidth}">
          <controls:FXDatePicker SelectedSolarDateTimeText="{Binding Entity.HeaderDate,Mode=TwoWay,ValidatesOnDataErrors=True}"/>
        </common:LayoutItem>
        <common:LayoutItem Label="شماره" Width="{StaticResource DefaultUnitWidth}">
          <TextBox Text="{Binding Entity.HeaderNumber,ValidatesOnDataErrors=True}" Style="{StaticResource TextBoxStyle}"/>
        </common:LayoutItem>
      </StackPanel>
    </StackPanel>
    <GroupBox Header="مواد داخلی">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListBox VerticalAlignment="Stretch" MinWidth="{StaticResource DefaultUnitWidth}" ItemsSource="{Binding InternalMaterials}"
                 SelectionMode="Single" SelectedItem="{Binding SelectedInternalMaterial}"
                 DisplayMemberPath="Caption">
          <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
              <i:InvokeCommandAction Command="{Binding AddToExternalMaterialCommand}"/>
            </i:EventTrigger>
          </i:Interaction.Triggers>
        </ListBox>
        <DataGrid Grid.Column="1" ItemsSource="{Binding Internals}" AutoGenerateColumns="False" AlternatingRowBackground="{x:Null}"
             CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="False"
                IsReadOnly="True"
             RowHeaderWidth="20">
          <DataGrid.Columns>
            <DataGridTextColumn Header="نوع مواد" Binding="{Binding Material.Caption,Mode=OneWay}" IsReadOnly="True"/>
            <DataGridTextColumn Header="قبض انبار" Binding="{Binding WarehouseBill.RowNumber,Mode=OneWay,ValidatesOnDataErrors=True}"/>
            <DataGridTextColumn Header="تاریخ ورود" Binding="{Binding WarehouseBill.EmissionDate,Mode=OneWay,ValidatesOnDataErrors=True}"/>
            <DataGridTextColumn Header="مقدار" Binding="{Binding MockValue,Mode=OneWay,ValidatesOnDataErrors=True}"/>
            <DataGridTextColumn Header="واحد" Binding="{Binding Material.Unit.Caption,Mode=OneWay}" IsReadOnly="True"/>
            <DataGridTextColumn Header="وزن" Binding="{Binding Weight,Mode=OneWay}"/>
          </DataGrid.Columns>
          <DataGrid.RowHeaderStyle>
            <Style TargetType="DataGridRowHeader">
              <Style.Triggers>
                <DataTrigger Binding="{Binding WarehouseBill}" Value="{x:Null}">
                  <Setter Property="Background" Value="Red"/>
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </DataGrid.RowHeaderStyle>
        </DataGrid>
      </Grid>
    </GroupBox>
    <GroupBox Header="مواد خارجی">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListBox VerticalAlignment="Stretch" MinWidth="{StaticResource DefaultUnitWidth}" ItemsSource="{Binding ExternalMaterials}"
                 SelectionMode="Single" SelectedItem="{Binding SelectedExternalMaterial}"
                 DisplayMemberPath="Caption">
          <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
              <i:InvokeCommandAction Command="{Binding AddToInternalMaterialCommand}"/>
            </i:EventTrigger>
          </i:Interaction.Triggers>
        </ListBox>

        <DataGrid Grid.Column="1" ItemsSource="{Binding Externals}" AutoGenerateColumns="False" AlternatingRowBackground="{x:Null}"
               CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="False"
                  IsReadOnly="True"
               RowHeaderWidth="20">
          <DataGrid.Columns>
            <DataGridTextColumn Header="نوع مواد" Binding="{Binding Material.Caption,Mode=OneWay}" IsReadOnly="True"/>
            <DataGridTextColumn Header="قبض انبار" Binding="{Binding WarehouseBill.RowNumber}"/>
            <DataGridTextColumn Header="تاریخ ورود" Binding="{Binding WarehouseBill.EmissionDate}"/>
            <DataGridTextColumn Header="مقدار" Binding="{Binding MockValue}"/>
            <DataGridTextColumn Header="واحد" Binding="{Binding Material.Unit.Caption,Mode=OneWay}" IsReadOnly="True"/>
            <DataGridTextColumn Header="وزن" Binding="{Binding Weight}"/>
          </DataGrid.Columns>
          <DataGrid.RowHeaderStyle>
            <Style TargetType="DataGridRowHeader">
              <Style.Triggers>
                <DataTrigger Binding="{Binding WarehouseBill}" Value="{x:Null}">
                  <Setter Property="Background" Value="Red"/>
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </DataGrid.RowHeaderStyle>
        </DataGrid>
      </Grid>
    </GroupBox>
    <StackPanel Orientation="Vertical">
      <StackPanel.Resources>
        <Style TargetType="TextBlock">
          <Setter Property="FontFamily" Value="{StaticResource FontFamilyReport}"/>
          <Setter Property="FontSize" Value="{StaticResource FontSize0X}"/>
          <Setter Property="Height" Value="{StaticResource DefaultUnitHeight}"/>
          <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="TextBox">
          <Setter Property="FontFamily" Value="{StaticResource FontFamilyReport}"/>
          <Setter Property="FontSize" Value="{StaticResource FontSize0X}"/>
          <Setter Property="Width" Value="{StaticResource KeepUnitWidth}"/>
          <Setter Property="Height" Value="{StaticResource DefaultUnitHeight}"></Setter>
          <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
        <Style TargetType="controls:FXDatePicker">
          <Setter Property="FontFamily" Value="{StaticResource FontFamilyReport}"/>
          <Setter Property="FontSize" Value="{StaticResource FontSize0X}"/>
          <Setter Property="Width" Value="{StaticResource KeepUnitWidth}"/>
          <Setter Property="Height" Value="{StaticResource DefaultUnitHeight}"></Setter>
          <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
      </StackPanel.Resources>
      <StackPanel Orientation="Horizontal">
        <TextBlock Text=" "/>
      </StackPanel>
      <StackPanel Orientation="Horizontal">
        <TextBlock Text="بر اساس درخواست شماره "/>
        <TextBox Text="{Binding Entity.RequestNumber,ValidatesOnDataErrors=True}"/>
        <TextBlock Text=" مورخ "/>
        <controls:FXDatePicker SelectedSolarDateTimeText="{Binding Entity.RequestDate,Mode=TwoWay}"/>
        <TextBlock Text=" بدینوسیله گواهی می نماید که واحد تولیدی آشیان سازه ویژن مستقر "/>
      </StackPanel>
      <StackPanel Orientation="Horizontal">
        <TextBlock Text=" در قطعه 43 به استناد مجوز کمیسیون ارزش افزوده به شماره "/>
        <TextBlock Text="{StaticResource TestimonyAddedValueNumber}"/>
        <TextBlock Text=" مورخ "/>
        <TextBlock Text="{StaticResource TestimonyAddedValueDate}"/>
        <TextBlock Text=" تعداد "/>
        <TextBlock Text="{Binding Entity.ProductCount}"/>
        <TextBlock Text=" "/>
        <TextBlock Text="{Binding Entity.PackingType}"/>
      </StackPanel>
      <StackPanel Orientation="Horizontal">
        <TextBlock Text=" به وزن خالص "/>
        <TextBlock Text="{Binding Entity.PureWeight}"/>
        <TextBlock Text=" کیلوگرم و وزن با ظرف "/>
        <TextBlock Text="{Binding Entity.RealWeight}"/>
        <TextBlock Text=" کیلوگرم کالا به شرح ذیل در منطقه تولید نموده است. "/>
      </StackPanel>
    </StackPanel>
  </StackPanel>
</common:UserControlBase>
